package com.lianzhihui.romeex.ui.trade.adapter;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lianzhihui.romeex.R;
import com.lianzhihui.romeex.bean.PledgeRecordsBean;

import java.util.List;

import static com.lianzhihui.romeex.utils.DateUtil.remaining;
import static com.lianzhihui.romeex.utils.DateUtil.sec2Date;

/**
 * ProjectName: romeex
 * Package: com.lianzhihui.romeex.ui.trade.adapter
 * ClassName: ExtractFragmentAdapter
 * Description: 提取适配器
 * Author: zhanghong
 * CreateDate: 2020/10/30 17:38
 * UpdateUser: 更新者：
 * UpdateDate: 2020/10/30 17:38
 * UpdateRemark: 更新说明：
 * Version: 1.0
 */
public class ExtractRecordAdapter extends BaseQuickAdapter<PledgeRecordsBean.PledgeRecordBean, BaseViewHolder> {

    Context mContext;

    public ExtractRecordAdapter(@Nullable Context mContext, @Nullable List<PledgeRecordsBean.PledgeRecordBean> data) {
        super(R.layout.item_extract_layout, data);
        this.mContext = mContext;
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, PledgeRecordsBean.PledgeRecordBean item) {

        String status = item.getStatusStr();
        
        helper.setText(R.id.tv_sum, item.getRusdBalance() + "");
        helper.setText(R.id.tv_status, status);
        if (item.getStatus() == 4||item.getStatus() == 6) {
            helper.setTextColor(R.id.tv_status, mContext.getResources().getColor(R.color.text999));
        } else {
            helper.setTextColor(R.id.tv_status, mContext.getResources().getColor(R.color.yellow));
        }
        helper.setText(R.id.tv_pledge_sum, item.getTotalRetBalance() + " " + mContext.getString(R.string.text_rex));

//        helper.setText(R.id.tv_date, DateUtil.sec2Date(item.getExtractTime()));

        if (status.equals("已提取")) {

            if (item.getCanRelease() == 1) {
                helper.setText(R.id.tv_date_name1, R.string.destroy_time);
            } else {
                helper.setText(R.id.tv_date_name1, R.string.release_time);
            }
            helper.setText(R.id.tv_destroy, remaining(item.getExpireTime()));
            //2
            helper.setText(R.id.tv_date_name2, R.string.extract_time);
            helper.setText(R.id.tv_date, remaining(item.getExtractTime()));
        }

        if (status.equals("已取消")) {
            helper.setText(R.id.tv_date_name1, R.string.cancel_time);
            helper.setText(R.id.tv_destroy, sec2Date(item.getCancelTime()));
            helper.setText(R.id.tv_date_name2, R.string.extract_time);
            helper.setText(R.id.tv_date, remaining(item.getExtractTime()));
        }

    }
}
